package tutorial

/**
 *
 * zhu.tan@gmail.com
 * Date: Aug 10, 2010
 */

object RegularExpression {
  val r = """.*?(\d+).*""".r
  val s = "--> 5 <---"
  s match {
    case r(n) => println("This will match the first group of r, " + n + ", to 5")
    case _ => println("Won't match")
  }

}


object RE2 {
  val r = """(\d+)""".r
  val s = "--> 5 <---"
  r findFirstIn s match {
    case Some(n) => println("Matches 5 to " + n)
    case _ => println("Won't match")
  }
}

object RegExpTest1 extends Application {
  def containsScala(x: String): Boolean = {
    val z: Seq[Char] = x
    z match {
      case Seq('s', 'c', 'a', 'l', 'a', rest@_*) =>
        println("rest is " + rest)
        true
      case Seq(_*) =>
        false
    }
  }
}


